


<div class="container content">
    <div class="trong-content">
	<div class="left">
	    <?php $this->renderPartial('//layouts/menu_left'); ?>
	</div><!--left-->
	<div class="center">

	    <div class="box update-account-box">
		<div class="new-mem">

		    <div class="title">
			Inbox
		    </div>
		    <div class="wrap-page">
			<div class="title-page"><strong>Message</strong></div>   
			<div class="content-page">
			    <?php
			    $this->breadcrumbs = array(
				ucfirst($this->module->id) => array('mailbox/inbox'),
				'Message',
			    );

			    $this->renderPartial('_menu');

			    $subject = ($conv->subject) ? $conv->subject : $this->module->defaultSubject;

			    if (strlen($subject) > 100) {
				$subject = substr($subject, 0, 100);
			    }
			    ?>
			    <div class="mailbox-message-list">


				<?php
				foreach (Yii::app()->user->getFlashes() as $key => $message) {
				    echo '<div class="flash-' . $key . '">' . $message . "</div>\n";
				}
				?>
				<div class="mailbox-message-subject  mailbox-ellipsis"><?php echo $subject; ?></div>

				<br />
				<?php
				$first_message = 1;
				foreach ($conv->messages as $msg):
				    $sender = $this->module->getUserName($msg->sender_id);
				    if (!$sender)
					$sender = $this->module->deletedUser;
				    ?>

    				<div class="mailbox-message-header">
    				    <div class="message-sender">
					    <?php
					    echo ($msg->sender_id == Yii::app()->user->id) ? 'You' : ucfirst($sender);
					    echo ($first_message) ? ' said' : ' replied';
					    ?></div>
    				    <div class="message-date"><?php echo date("m-d-Y", $msg->created); ?></div>
    				    <br />
    				</div>
    				<div class="mailbox-message-text"><?php echo $msg->text; ?></div>
    				<br />
				    <?php
				    $first_message = 0;
				endforeach;

				if ($this->module->authManager)
				    $authReply = Yii::app()->user->checkAccess("Mailbox.Message.Reply");
				else
				    $authReply = $this->module->sendMsgs;

				if ($authReply) {

				    $form = $this->beginWidget('CActiveForm', array(
					'action' => $this->createUrl('message/reply', array('id' => $_GET['id'])),
					'id' => 'message-reply-form',
					'enableAjaxValidation' => false,
				    ));
				    ?>
    				<div class="mailbox-message-reply ui-helper-clearfix">
					<?php /* echo $form->errorSummary(array($reply,$conv)); */ ?>
					<?php echo $form->error($reply, 'text'); ?>
    				    <div class="mailbox-textarea-wrap ui-helper-clearfix">
    					<textarea name="text" cols="50" rows="7" placeholder="Reply here..."></textarea>
    				    </div>
    				    <input type="submit" class="btn btn-large mailbox-input" value="Send Reply" />
    				</div>



				    <?php
				    $this->endWidget();
				}
				?>
			    </div>

			</div>
		    </div>


		</div>		
	    </div><!--box-->

	</div><!--center-->
	<div class="right">

	    <?php $this->widget('application.widgets.leftprofile.PercentComplete') ?>
	    <?php $this->widget('application.widgets.leftprofile.Interested'); ?>

	</div><!--right-->

    </div><!--trong-content-->


</div><!--content-->
